from scipy.signal import butter, filtfilt
import numpy as np

# 设计低通滤波器
b, a = butter(4, 0.1, 'low')

# 生成信号
t = np.linspace(0, 1, 1000, endpoint=False)
signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000)

# 应用滤波器
filtered_signal = filtfilt(b, a, signal)